<template>
	<view>
		<u-cell-group>
			<u-cell-item title="修改密码" @click="toPassword"></u-cell-item>
			<u-cell-item title="账号注销" @click="showDialogCancel"></u-cell-item>
		</u-cell-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			toPassword(){
				uni.navigateTo({
					url:'/pages/tab/mine/password/password'
				})
			},
			showDialogCancel(){
				uni.showModal({
					title: "操作确认",
					content: "注销后将保留7日数据，中途登录后自动取消注销状态，账号注销后该所有数据清空将无法恢复。",
					success: (res) => {
						if (res.confirm) {
							this.requestUnregist()
						}
					}
				})
			},
			
			async requestUnregist(){
				let res = await this.$common.post('/app/setup/writeOff');
				if(0 == res.code){
					uni.showToast({
						title: "注销成功",
						icon: 'none'
					});
					setTimeout(()=>{
						//应用退出到登录界面
						uni.reLaunch({
							url: '/pages/login/login',
						});
						this.clearUserCache();
					}, 1000)
				}
			},
			clearUserCache(){
				uni.removeStorageSync('login');
				uni.removeStorageSync('token');
				uni.removeStorageSync('userId');
				uni.removeStorageSync('userName');
				uni.removeStorageSync('userPic');
				uni.removeStorageSync('userSex');
				uni.removeStorageSync('userTxCode');
			},
		}
	}
</script>

<style lang="scss" scoped>
	
	

</style>
